package com.wenhao.iqiyi;

import java.util.Scanner;
import java.util.concurrent.Semaphore;
import java.util.function.IntConsumer;

public class Main3 {
    public static void main(String[] args) {
        final Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        ZeroEvenOdd zeroEvenOdd = new ZeroEvenOdd(n);
        new Thread(() -> {
            try {
                zeroEvenOdd.printZero(System.out::print);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
        new Thread(() -> {
            try {
                zeroEvenOdd.printEven(System.out::print);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
        new Thread(() -> {
            try {
                zeroEvenOdd.printOdd(System.out::print);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
    }
}

class ZeroEvenOdd {
    private int n;

    private int number = 1;
    Semaphore zero = new Semaphore(1);
    Semaphore odd = new Semaphore(0);
    Semaphore even = new Semaphore(0);

    public ZeroEvenOdd(int n) {
        this.n = n;
    }

    // printNumber.accept(x) outputs "x", where x is an integer.
    public void printZero(IntConsumer printNumber) throws InterruptedException {
        while (number < n) {
            zero.acquire();
            printNumber.accept(0);
            if (number % 2 == 1) {
                odd.release();
            } else {
                even.release();
            }
        }
    }

    public void printEven(IntConsumer printNumber) throws InterruptedException {
        while (number < n) {
            odd.acquire();
            if (number % 2 == 1) {
                printNumber.accept(number++);
            }
            zero.release();
        }
    }

    public void printOdd(IntConsumer printNumber) throws InterruptedException {
        while (number < n) {
            even.acquire();
            if (number % 2 == 0) {
                printNumber.accept(number++);
            }
            zero.release();
        }
    }
}
